package com.wss.lsl.mongo.demo.config;

import java.net.UnknownHostException;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.authentication.UserCredentials;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;

import com.mongodb.MongoClient;

@Configuration
public class SpringMongoConfig2 {

	@Bean
	public MongoDbFactory mongoDbFactory() throws UnknownHostException {

		return new SimpleMongoDbFactory(new MongoClient("localhost", 27017),
				"test", new UserCredentials("wss", "wss"));
	}

	@Bean
	public MongoTemplate mongoTemplate() throws UnknownHostException {

		return new MongoTemplate(mongoDbFactory());
	}
}
